home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Singles Flirt Up Your Life! (German)
/
Singles Flirt Up Your Life.iso
/
data1.cab
/
Statemachine
/
walk.lua
< prev
Wrap
Text File
|
2004-01-29
|
14KB
|
573 lines
-- walk state machine
beginStateMachine()
onEnter(function(msg)
setState("stand");
end )
onReturn(function(msg)
nextAction();
end )
onMsg("queue", function(msg)
nextAction();
end )
onMsg("waitForChar", function(msg)
--cancel();
print("interaction." .. msg.data);
enterStateMachine("interaction." .. msg.data);
end )
onMsg("enterStateMachine", function(msg)
print("enterStateMachine :" .. msg.data);
enterStateMachine(msg.data);
end )
-- emotion pose messages
onMsg("emoThink", function(msg)
print("think");
setState("think");
end )
onMsg("emoHungry", function(msg)
print("hungry");
setState("hungry");
end )
onMsg("emoYawn", function(msg)
print("yawn");
setState("yawn");
end )
onMsg("emoHygiene", function(msg)
print("Elaine hygiene");
setState("hygiene");
end )
onMsg("emoSwing", function(msg)
print("swing");
setState("swing");
end )
onMsg("emoHappy", function(msg)
print("happy");
setState("happy");
end )
onMsg("emoFlirt", function(msg)
print("flirt");
storeData("flirtChar", msg.sender);
setState("flirt");
end )
onMsg("emoRefuse", function(msg)
print("refuse");
setState("refuse");
end )
onMsg("emoRefuseChar", function(msg)
print("onMsg emoRefuseChar");
storeData("refuseChar", msg.sender);
setState("refuseChar");
end )
onMsg("emoShameChar", function(msg)
print("onMsg emoShameChar");
storeData("shameChar", msg.sender);
setState("shameChar");
end )
onMsg("emoShameNackedChar", function(msg)
print("onMsg emoShameNackedChar");
storeData("shameChar", msg.sender);
setState("shameNackedChar");
end )
onMsg("emoYouSmell", function(msg)
print("you smell");
storeData("smellChar", msg.sender);
setState("youSmell");
end )
onMsg("goAway", function(msg)
print("onMsg goAway(walk)");
if (isWalking()) then return end;
local minDist = 1.5;
local maxDist = 3.0;
local dataNum = tonumber(msg.data)
if (dataNum) then
minDist = dataNum;
maxDist = dataNum * 2;
end
local target = getParent().findPointNear(minDist, maxDist);
if (target) then
print("goAway min dist " .. minDist);
getParent().queueWalkActionPoint("pm_walk", target, true);
else
print("goAway no target");
end
end )
-- stand : walk returns into this state -> fast fading
state("stand")
onEnter(function(msg)
print("stand " .. getParent().getCharacterName())
-- mission test
getParent().getGameObjectServer().mission.sendMsgThis("checkComplete");
setPose(archize(getParent(), "stand1"));
sendDelayedMsgThis("complete", STAND_POSE_COMPLETE_TIME);
end )
onMsg("complete", function(msg)
actionComplete();
end )
onMsg("end", function(msg)
setDelayedState("stand2", random(1000, 3000));
--actionComplete();
end )
-- same as stand but longer fadetime
state("stand1")
onEnter(function(msg)
print("stand1 " .. getParent().getCharacterName())
-- mission test
getParent().getGameObjectServer().mission.sendMsgThis("checkComplete");
--setPose("standElaine");
print("stand1 anim: " .. archize(getParent(), "stand1"));
startAnimation(archize(getParent(), "stand1"), false, 1.0, STAND_POSE_FADE_TIME);
sendDelayedMsgThis("complete", STAND_POSE_COMPLETE_TIME);
end )
onMsg("complete", function(msg)
actionComplete();
end )
onMsg("end", function(msg)
setDelayedState("stand" .. randomExclude(1, 4, {1}), random(1000, 3000));
end )
state("stand2")
onEnter(function(msg)
print("stand2 " .. getParent().getCharacterName())
--setPose("stand2Elaine");
print("stand2 anim: " .. archize(getParent(), "stand2"));
startAnimation(archize(getParent(), "stand2"), false, 1.0, STAND_POSE_FADE_TIME);
sendDelayedMsgThis("complete", STAND_POSE_COMPLETE_TIME);
end )
onMsg("complete", function(msg)
actionComplete();
end )
onMsg("end", function(msg)
setDelayedState("stand" .. randomExclude(1, 4, {2}), random(1000, 3000));
end )
state("stand3")
onEnter(function(msg)
print("stand3 " .. getParent().getCharacterName())
--setPose("stand3Elaine");
print("stand3 anim: " .. archize(getParent(), "stand3"));
startAnimation(archize(getParent(), "stand3"), false, 1.0, STAND_POSE_FADE_TIME);
sendDelayedMsgThis("complete", STAND_POSE_COMPLETE_TIME);
end )
onMsg("complete", function(msg)
actionComplete();
end )
onMsg("end", function(msg)
setDelayedState("stand" .. randomExclude(1, 4, {3}), random(1000, 3000));
end )
state("stand4")
onEnter(function(msg)
print("stand4 " .. getParent().getCharacterName())
--setPose("stand4Elaine");
print("stand4 anim: " .. archize(getParent(), "stand4"));
startAnimation(archize(getParent(), "stand4"), false, 1.0, STAND_POSE_FADE_TIME);
sendDelayedMsgThis("complete", STAND_POSE_COMPLETE_TIME);
end )
onMsg("complete", function(msg)
actionComplete();
end )
onMsg("end", function(msg)
setDelayedState("stand" .. randomExclude(1, 4, {4}), random(1000, 3000));
end )
state("think")
onEnter(function(msg)
print("setPose(emoThink)");
setPose("emoThink");
sendDelayedMsgThis("complete", EMO_POSE_COMPLETE_TIME);
end )
onMsg("complete", function(msg)
this.actionComplete();
end )
onMsg("end", function(msg)
setState("stand");
end )
state("hungry")
onEnter(function(msg)
setPose("emoHungry");
this.actionComplete();
end )
onMsg("end", function(msg)
setState("stand");
end )
state("yawn")
onEnter(function(msg)
setPose("emoYawn");
this.actionComplete();
end )
onMsg("end", function(msg)
setState("stand");
end )
state("hygiene")
onEnter(function(msg)
setPose("emoHygiene");
this.actionComplete();
end )
onMsg("end", function(msg)
setState("stand");
end )
state("swing")
onEnter(function(msg)
setPose("emoSwingArms");
this.actionComplete();
end )
onMsg("end", function(msg)
setState("stand");
end )
state("happy")
onEnter(function(msg)
setPose("emoHappy");
this.actionComplete();
end )
onMsg("end", function(msg)
setState("stand");
end )
state("flirt")
onEnter(function(msg)
local partner = getStateObjectFromID(retrieveData("flirtChar"));
if (partner) then
turnToGameObject(partner)
setPose("emoFlirt");
this.actionComplete();
else
print("flirtChar not found");
setState("stand");
end
end )
onMsg("end", function(msg)
setState("stand");
end )
state("refuseChar")
onEnter(function(msg)
print("refuseChar onEnter");
local partner = getStateObjectFromID(retrieveData("refuseChar"));
if (partner) then
turnToGameObject(partner)
setPose("emoRefuse");
this.actionComplete();
else
print("refuseChar not found");
setState("stand");
end
end )
onMsg("end", function(msg)
setState("stand");
end )
state("shameChar")
onEnter(function(msg)
print("state shameChar");
local partner = getStateObjectFromID(retrieveData("shameChar"));
--getOtherCharcter(getParent());
if (partner) then
turnToGameObject(partner);
setPose("emoShy");
getParent().setEmoticon(EMOTICON_SHY, EMOTICON_DELAY);
--this.actionComplete();
else
print("shameChar not found");
setState("stand");
return
end
this.actionComplete();
-- sendDelayedMsgThis("complete", SHY_POSE_COMPLETE_TIME);
end )
-- onMsg("complete", function(msg)
-- actionComplete();
-- end )
onMsg("end", function(msg)
setState("stand");
end )
state("shameNackedChar")
onEnter(function(msg)
print("state shameChar");
local partner = getStateObjectFromID(retrieveData("shameChar"));
--getOtherCharcter(getParent());
if (partner) then
turnToGameObject(partner);
setPose("emoShyNacked");
getParent().setEmoticon(EMOTICON_SHY, EMOTICON_DELAY);
--this.actionComplete();
else
print("shameChar not found");
setState("stand");
return
end
sendDelayedMsgThis("complete", SHY_POSE_COMPLETE_TIME);
end )
onMsg("complete", function(msg)
actionComplete();
end )
onMsg("end", function(msg)
local other, result = getDisturbingChar(getParent(), "showNaked")
if testCancel() or (not other) then
setState("stand");
else
if (not urgentOutfitChange(getParent())) then
setPose("emoShyNackedLoop");
getParent().setEmoticon(EMOTICON_SHY, EMOTICON_DELAY);
sendDelayedMsgThis("complete", SHY_POSE_COMPLETE_TIME);
end
end
end )
state("refuse")
onEnter(function(msg)
setPose("emoRefuse");
this.actionComplete();
end )
onMsg("end", function(msg)
setState("stand");
end )
state("youSmell")
onEnter(function(msg)
--local partner = getOtherCharcter(getParent());
local partner = getStateObjectFromID(retrieveData("smellChar"));
if (partner) then
turnToGameObject(partner)
setPose("emoYouSmell");
this.actionComplete();
else
print("smellChar not found");
setState("stand");
end
end )
onMsg("end", function(msg)
setState("stand");
end )
-- state("goAway")
-- onEnter(function(msg)
-- print("goAway onEnter");
-- local target = getParent().findPointNear(2.0, 5.0);
-- if (target) then
-- if (not walkToActionPoint(target)) then
-- print("no path");
-- end
-- else
-- print("no target");
-- end
-- end )
-- state("goAway")
-- onEnter(function(msg)
-- print("goAway onEnter");
-- local target = getParent().findPointNear(2.0, 5.0);
-- if (target) then
-- getParent().queueWalkActionPoint("pm_walk", target, true);
-- else
-- print("no target");
-- end
-- end )
-- walk
state("walk")
onEnter(function(msg)
print("walk onEnter " .. getParent().getCharacterName());
-- if distance to walk is greater 4m, run
if isRunDistance() then
setState("runRFF-runLFF");
else
--startWalk("stand-walkLFF-Elaine", "stand-walkLFF-Elaine");
local c = getParent();
startWalk(archizeWalk(c, "stand-walkLFF-"), archizeWalk(c, "stand-walkLFF-"), WALK_SPEEDUP);
end
end )
onMsg("next", function(msg)
if testCancel() then
stopWalk();
nextAction();
else
setState("walkLFF-walkRFF");
end
end )
onMsg("end", function(msg)
nextAction();
--notify mission
getStateObjectFromID(msg.sender).getParent().sendMsg("arrived",getParent().getGameObjectServer().mission);
end )
state("walkRFF-walkLFF")
onEnter(function(msg)
if isRunDistance() then
setState("runRFF-runLFF");
else
--startWalk("walkRFF-walkLFF-Elaine", "walkRFF-stand-Elaine");
local c = getParent();
startWalk(archizeWalk(c, "walkRFF-walkLFF-"), archizeWalk(c, "walkRFF-stand-"), WALK_SPEEDUP);
createDirt(DIRT_FOOTSTEP, WALK_DIRT_SIZE, WALK_DIRT_PROBABILITY);
makeStepSound();
end
end )
onMsg("next", function(msg)
if testCancel() then
stopWalk();
nextAction();
else
setState("walkLFF-walkRFF");
end
end )
onMsg("end", function(msg)
nextAction();
--notify mission
getStateObjectFromID(msg.sender).getParent().sendMsg("arrived",getParent().getGameObjectServer().mission);
end )
state("walkLFF-walkRFF")
onEnter(function(msg)
--startWalk("walkLFF-walkRFF-Elaine", "walkLFF-stand-Elaine");
local c = getParent();
startWalk(archizeWalk(c, "walkLFF-walkRFF-"), archizeWalk(c, "walkLFF-stand-"), WALK_SPEEDUP);
makeStepSound();
end )
onMsg("next", function(msg)
if testCancel() then
stopWalk();
nextAction();
else
setState("walkRFF-walkLFF");
end
end )
onMsg("end", function(msg)
nextAction();
--notify mission
getStateObjectFromID(msg.sender).getParent().sendMsg("arrived",getParent().getGameObjectServer().mission);
end )
-- run
state("runRFF-runLFF")
onEnter(function(msg)
--startWalk("runRFF-runLFF-Elaine", "walkRFF-stand-Elaine");
local c = getParent();
startWalk(archizeRun(c, "runRFF-runLFF-"), archizeWalk(c, "walkRFF-stand-"), RUN_SPEEDUP);
createDirt(DIRT_FOOTSTEP, WALK_DIRT_SIZE, WALK_DIRT_PROBABILITY);
makeStepSound();
end )
onMsg("next", function(msg)
if testCancel() then
stopWalk();
nextAction();
else
setState("runLFF-runRFF");
end
end )
onMsg("end", function(msg)
nextAction();
--notify mission
getStateObjectFromID(msg.sender).getParent().sendMsg("arrived",getParent().getGameObjectServer().mission);
end )
state("runLFF-runRFF")
onEnter(function(msg)
--startWalk("runLFF-runRFF-Elaine", "walkLFF-stand-Elaine");
local c = getParent();
startWalk(archizeRun(c, "runLFF-runRFF-"), archizeWalk(c, "walkLFF-stand-"), RUN_SPEEDUP);
createDirt(DIRT_FOOTSTEP, WALK_DIRT_SIZE, WALK_DIRT_PROBABILITY);
makeStepSound();
end )
onMsg("next", function(msg)
if testCancel() then
stopWalk();
nextAction();
else
setState("runRFF-runLFF");
end
end )
onMsg("end", function(msg)
nextAction();
--notify mission
getStateObjectFromID(msg.sender).getParent().sendMsg("arrived",getParent().getGameObjectServer().mission);
end )
endStateMachine()